import { createSlice,createAsyncThunk } from "@reduxjs/toolkit";
import { movieListRequest } from "../../api";


export const getMovieListAction = createAsyncThunk('movie/getMovieList',async()=>{
  const result = await movieListRequest()
  console.log(result);
  return result.data.data.list
})
const movieSlice = createSlice({
  name:'movie',
  initialState:{
    movieList:[]
  },
  reducers:{

  },
  extraReducers:{
    [getMovieListAction.fulfilled](prev,action){
      prev.movieList = action.payload
      console.log('getMovieListAction执行完成');

    },
    [getMovieListAction.pending](){
      console.log('getMovieListAction正在执行中');
    }
  }

})

export default movieSlice.reducer
